<?php
/**
 * Zend Framework Contribution
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Mwb
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    1.0 ForeignKeys.php 3 mai 2012 Sergio DE VASCONCELOS
 */

require_once('Zend/Mwb/Dom/Abstract.php');
require_once('Zend/Mwb/Dom/ForeignKey.php');

/**
 * MySQL Workbench document
 *
 * @category   Zend
 * @package    Zend_Mwb
 */
class Zend_Mwb_Dom_ForeignKeys extends Zend_Mwb_Dom_Abstract implements Iterator, Countable
{
	protected $foreignKeys;
	protected $key = 0;
	protected $count = 0;
	
	public function parse() {
		$dom = $this->node;// DOMNodeList
		$this->foreignKeys = array();

        foreach($dom as $child) {
        	if ($child->nodeName=='value') {
        		$this->foreignKeys[] = new Zend_Mwb_Dom_ForeignKey($child, $this);
	            $this->count++;
        	}
        }
	}
	
	/**
	 * return DOMNode
	 */
	public function create() {
		
	}
	
	/**
	 * return Zend_Mwb_Dom_Schemata
	 */
	public function current () {return $this->foreignKeys[$this->key]; }
	public function next () {$this->key++;}
	public function key () {return $this->key;}
	public function valid () { return isset($this->foreignKeys[$this->key]); }
	public function rewind () {$this->key = 0;}
	public function count () {return $this->count;}
}
/*
<value _ptr_="0x5e01830" type="list" content-type="object" content-struct-name="db.mysql.ForeignKey" key="foreignKeys">
	<value type="object" struct-name="db.mysql.ForeignKey" id="{01F816F6-3434-4E4E-866E-99F3132FCAA9}" struct-checksum="0x70a8fc40">
		<link type="object" struct-name="db.mysql.Table" key="referencedTable">{118E286C-8E04-460F-A94E-25DAF3F78411}</link>
		<value _ptr_="0x5e05660" type="list" content-type="object" content-struct-name="db.Column" key="columns">
			<link type="object">{9BCBC904-09A9-4C9F-8B3D-1AC024FB379D}</link>
		</value>
		<value type="int" key="deferability">0</value>
		<value type="string" key="deleteRule">NO ACTION</value>
		<link type="object" struct-name="db.Index" key="index">{464FF655-62EB-4BAA-8ADD-D4FE0F08BCB3}</link>
		<value type="int" key="mandatory">1</value>
		<value type="int" key="many">1</value>
		<value type="int" key="modelOnly">0</value>
		<link type="object" struct-name="db.Table" key="owner">{D1F6E044-B27A-4136-A250-0C5866B2F630}</link>
		<value _ptr_="0x5e056f0" type="list" content-type="object" content-struct-name="db.Column" key="referencedColumns">
			<link type="object">{CBEB303F-D730-442F-B753-5CD2975FE0A3}</link>
		</value>
		<value type="int" key="referencedMandatory">1</value>
		<value type="string" key="updateRule">NO ACTION</value>
		<value type="string" key="comment"></value>
		<value type="string" key="name">id_access</value>
		<value type="string" key="oldName">id_access</value>
	</value>
	
	<value type="object" struct-name="db.mysql.ForeignKey" id="{02FE1CCB-6506-49EA-A61B-B823ECE87F26}" struct-checksum="0x70a8fc40">
		<link type="object" struct-name="db.mysql.Table" key="referencedTable">{4BC5695A-AB18-451F-806A-5FC0114B4FDC}</link>
        <value _ptr_="0x5e05d80" type="list" content-type="object" content-struct-name="db.Column" key="columns">
        	<link type="object">{E106C297-0D61-499C-9EF4-BD46DBC995AF}</link>
        </value>
        <value type="int" key="deferability">0</value>
        <value type="string" key="deleteRule">NO ACTION</value>
        <link type="object" struct-name="db.Index" key="index">{715DFAC7-4125-40F4-948C-E2C3679B2F96}</link>
        <value type="int" key="mandatory">1</value>
        <value type="int" key="many">1</value>
		<value type="int" key="modelOnly">0</value>
        <link type="object" struct-name="db.Table" key="owner">{D1F6E044-B27A-4136-A250-0C5866B2F630}</link>
		<value _ptr_="0x5e05e10" type="list" content-type="object" content-struct-name="db.Column" key="referencedColumns">
        	<link type="object">{DD8A67A4-1535-448C-9FAB-DC8EC59F1D86}</link>
        </value>
        <value type="int" key="referencedMandatory">1</value>
        <value type="string" key="updateRule">NO ACTION</value>
        <value type="string" key="comment"></value>
        <value type="string" key="name">id_access1</value>
    	<value type="string" key="oldName">id_access1</value>
	</value>
</value>

 */